<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo LANG('admin_index');?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache" />
<link href="<?php echo CSS_PATH . 'admin_index.css'?>" type="text/css" rel="stylesheet" />
<link href="<?php echo CSS_PATH . 'dialog.css'?>" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo JS_PATH . 'jquery.1.5.1.js';?>?v=0001"></script>
<script type="text/javascript" src="<?php echo JS_PATH . 'dialog.js';?>?v=0001"></script>
<script type="text/javascript" src="<?php echo JS_PATH . 'common.js';?>?v=0005"></script>
<script type="text/javascript">
$(function()
{
	var windowH = $(window).height();
	$('#mainright').attr({height : windowH - 80});
	$(window).resize(function()
	{
		var nwindowH = $(window).height();
		$('#mainright').attr({height : nwindowH - 80});
	});
});
</script>
</head>
<body scroll="no" style="overflow: hidden;">
<div id="layerbox"></div>
<table id="mytable" width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" height="80" valign="top"><div id="header">
        <div class="logo fl">
          <div class="png"> <a href="javascript:void(0);"><img src="<?php echo IMG_PATH , 'jiajiao/logo.png';?>" /></a> </div>
          <div class="lun"><a href="index.php" target="_blank"><?php echo LANG('homepage')?></a>&nbsp;&#8211;&nbsp;<a href="#"><?php echo LANG('admin_page')?></a></div>
        </div>
        <ul class="nav">
          <li class="home"> <a style="cursor:pointer" href="javascript:void(0);" onclick="initguide('homepage');">首页</a> </li>
          <?php foreach($menus['title'] as $key => $value){if($key == 'homepage'){continue;}?>
          <li id="<?php echo $key;?>" onmouseover="showguide('<?php echo $key;?>');"> <a style="cursor:pointer" href="javascript:void(0);" onclick="return initguide('<?php echo $key;?>');"><?php echo $value;?></a> </li>
          <?php }?>
          <li class="more" id="more" onmouseover="showmenu('more')"><a href="javascript:void(0);">菜单</a></li>
        </ul>
        <div class="nav_right">
        <a href="#" class="lock_screen">锁屏</a><span>|</span>
        <a href="#">网站地图</a><span>|</span>
        <a href="#">更新缓存</a><span>|</span>
        <a href="#">帮助</a>
        </div>
        <div id="guide">
          <div class="wei fl" id="pos"></div>
          <ul class="fr">
          </ul>
        </div>
      </div></td>
  </tr>
  <tr>
    <td valign="top" id="main-fl"><div id="left">
        <h1></h1>
        <div class="cc"></div>
        <ul>
        </ul>
      </div></td>
    <td valign="top" id="mainright" height="100%">
    <iframe name="main" id="main" width="100%" height="100%" frameborder="0" scrolling="auto" style="overflow: visible;" src=""></iframe>
    </td>
  </tr>
</table>
<div style="display: none;" id="showmenu">
  <dl>
    <dd></dd>
  </dl>
</div>
</body>
</html>
<script type="text/javascript">
/**
 * 添加快捷菜单
 */
function add_panel(id)
{
	var data = 'menuid=' + id;
	var ajax = get_ajax();
	ajax.open('POST', 'index.php?m=admin&c=index&a=add_panel', true);
	ajax.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	ajax.send(data);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 4 && ajax.status == 200)
		{
			var response = ajax.responseText;
			if(response)
			{
				art.dialog({title:'提示', content:'<span class="green">快捷方式添加成功</span>', fixed:true, time:1}, function(){});
			}
		}
	}
}

var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf('msie')!=-1) && (agt.indexOf('opera')==-1));
var is_gecko= (navigator.product == "Gecko");
var is_ns = (document.layers);
var is_w3 = (document.getElementById && !is_ie);
var sch = 0;
var guides = <?php echo $guides;?>;
var titles = <?php echo $title;?>;
var cate   = 'common';
var action = '';
var type   = '';
//document.getElementById('mainright');
function showmenu(id)
{
	var obj = document.getElementById('showmenu');
	var my_menu = <?php echo $my_menu ? $my_menu : '[]';?>;
	var html  = '<dl><dd>';
	for(var i = 0; i <my_menu.length; i ++)
	{
		html += '<a href="javascript:void(0);" onclick="return initguide(\'' + my_menu[i].parent + '\',\'' + my_menu[i].name + '\')">' + my_menu[i].title + '</a>';
	}
	obj.innerHTML = html + '</dd></dl>';
	var obj1  = document.getElementById(id);
	var left  = findPosX(obj1) + ietruebody().scrollLeft;
	var top   = findPosY(obj1) + ietruebody().scrollTop + 22;
	if(my_menu.length> 0)
	{
		obj.style.display = "";
	}
	obj.style.top	= top + 'px';
	obj.style.left	= left + 'px';
	addEvent(document,"mouseout",doc_mouseout);
}

function showguide(id){
	var obj = document.getElementById('showmenu');
	var guide = guides[id];
	var html  = '<dl>';
	for(i in guide){
		var subs = guide[i];
		html += '<dd>';
		for(j in subs){
			var subss = subs[j];
			html += '<a href="javascript:void(0);" onclick="return initguide(\''+id+'\',\''+j+'\')">'+subss[0]+'</a>';
		}
		html += '</dd>';
	}
	obj.innerHTML = html + '</dl>';
	var obj1  = document.getElementById(id);
	var left  = findPosX(obj1) + ietruebody().scrollLeft;
	var top   = findPosY(obj1) + ietruebody().scrollTop + 22;
	obj.style.display = "";
	obj.style.top	= top + 'px';
	obj.style.left	= left + 'px';
	addEvent(document,"mouseout",doc_mouseout);
}
function closeguide(){
	var obj = document.getElementById('showmenu');
	obj.style.display = "none";
	removeEvent(document,"mouseout",doc_mouseout);
}
function upleft(t){
	var obj  = document.getElementById('left');
	var objli = obj.getElementsByTagName('li');
	var obja = obj.getElementsByTagName('a');
	for(var i=0;i<obja.length;i++){
		objli[i].className = obja[i].id==t ? 'one' : '';
	}
}
function showleft(id,t,url){
	cate = id;
	var obj = document.getElementById('left');
	
	var html = '';
	var guide = guides[id];
	url = typeof url != 'undefined' ? url : '';
	type = typeof t != 'undefined' ? t : '';
 
	for(i in guide){
		var subs = guide[i];
		html += '<h1>' + titles[i] + '</h1><div class="cc"></div><ul>';
		for(j in subs){
			var sub = subs[j];
			html += '<li><a id="'+j+'" href="javascript:void(0);" onclick="return initguide(\''+id +'\',\''+j+'\')">'+sub[0]+'</a></li>';
			if(url==''){
				if(type == ''){
					url = sub[1];
					type = j;
				} else if(j == type){
					url = sub[1];
				}
				action = i;
			}
		}
		html += '</ul>';
	}
	obj.innerHTML = html;
	upleft(type);
	if (is_ie && sch>0) sch = 0;
	//parent.main.location = url;
	document.getElementById('main').src = url;
	return false;
}
function showtitle(){
	var obj = document.getElementById('guide');
	var guide = guides[cate];
	var html = '';
	if (cate && action && type) {
		if (cate=='common') {
			html += '<div class="wei fl"><a href="javascript:void(0)" onclick="return initguide(cate,type,\'?m=admin&c=index&a=main\')">首页</a> &raquo; <a href="javascript:void(0);" onclick="return initguide(cate,type,\'?m=admin&c=index&a=main\')">'+titles[action]+'</a> &raquo; <a href="javascript:void(0);">'+guide[action][type][0]+'</a>&nbsp;<a href="javascript:add_panel(' + guide[action][type][2] + ');" title="添加到快捷菜单">[+]</a></div>';
		} else {
			html += '<div class="wei fl"><a href="javascript:void(0)" onclick="return initguide(cate,type,\'?m=admin&c=index&a=main\')">首页</a> &raquo; <a href="javascript:void(0);" onclick="return initguide(\''+cate+'\')">'+titles[action]+'</a> &raquo; <a href="javascript:void(0);" onclick="return initguide(\''+cate+'\',\''+type+'\')">'+guide[action][type][0]+'</a>&nbsp;<a href="javascript:add_panel(' + guide[action][type][2] + ');" title="添加到快捷菜单">[+]</a></div>';
		}
	}
	html += '<ul class="fr"><li class="home"><?php  echo LANG('username'); echo '：', $username;?></li><li>角色：<?php echo $role;?></li><li><a class="s0" style="cursor:pointer" onclick="parent.main.location.reload();" title="刷新主页面">刷新</a></li><li><a class="s0" style="cursor:pointer" onclick="parent.main.history.go(-1);" title="后退到前一页">后退</a></li><li><a href="?m=admin&c=index&a=logout" title="<?php echo LANG('logout')?>"><?php echo LANG('logout')?></a></li></ul>';
	if (is_ie || is_ns || is_w3 && agt.indexOf('opera')==-1)
	{
		html;
	}
	obj.innerHTML = html;
}
function initguide(id,t,url){
	showleft(id,t,url);
	showtitle();
	return false;
}
function doc_mousedown(e){
	var e = is_ie ? event: e;
	obj	= document.getElementById("menu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + ietruebody().scrollTop : e.pageY;
	_x1 = obj.offsetLeft;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = obj.offsetTop - 20;
	_y2 = obj.offsetTop + obj.offsetHeight;
 
	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
	   closemenu();
	}
}
function doc_mouseout(e){
	var e = is_ie ? event: e;
	obj	= document.getElementById("showmenu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + ietruebody().scrollTop : e.pageY;
	_x1 = obj.offsetLeft + 2;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = obj.offsetTop - 20;
	_y2 = obj.offsetTop + obj.offsetHeight;
 
	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
		closeguide();
	}
}
function IsElement(id){
	return document.getElementById(id)!=null ? true : false;
}
function addEvent(el,evname,func){
	if(is_ie){
		el.attachEvent("on" + evname,func);
	} else{
		el.addEventListener(evname,func,true);
	}
};
function removeEvent(el,evname,func){
	if(is_ie){
		el.detachEvent("on" + evname,func);
	} else{
		el.removeEventListener(evname,func,true);
	}
};
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft - ietruebody().scrollLeft;
}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y){
		curtop += obj.y;
	}
	return curtop - ietruebody().scrollTop;;
}
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
//initguide(cate,type,'?m=admin&c=index&a=main');
initguide('homepage');
//parent.main.location.reload();
</script>